<?php

require 'vendor/autoload.php';

$client = new JRClient\Client('tcp', '127.0.0.1:3999');  // 连接到一个服务器的 rpc 服务

$result = $client->call('Arith.Multiply', ['A' => 3, 'B' => 36], 1000);  // 开启一个远程调用, 参数一为要调用的服务和方法 , 函数调用参数在参数二 , 参数三为超时
if ($result['error']) {  // 调用失败
    echo $result['errorMsg'] . "\n";
} else {
    var_dump($result['data']);
}

$result = $client->call('Arith.Divide', ['A' => 29, 'B' => 4], 2000);
if ($result['error']) {
    echo $result['errorMsg'] . "\n";
} else {
    var_dump($result['data']);
}

$result = $client->call('Human.GetAge',['Name' => 'jack', 'Age' => 19], 1000);
if ($result['error']) {
    echo $result['errorMsg'] . "\n";
} else {
    var_dump($result['data']);
}
